/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package demo.hotel;

import java.util.Scanner;

/**
 *
 * @author VANDH
 */
public class HotelDetails {
    // instance variable

    int n = 0;
    String[] hotelNameArray = new String[10];
    String[] ownerNameArray = new String[10];
    String[] locationArray = new String[10];
    double[] tariffArray = new double[10];

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        HotelDetails hd = new HotelDetails();
        hd.enterDetails();
        hd.searchHotel();

    }

    /* Xử lí nhập/lưu thông tin khách sạn vô mảng
     */
    public void enterDetails() {
        // Duyệt mảng, nhập
        Scanner keyboard = new Scanner(System.in);
        System.out.printf("How many hotels : ");
        n = keyboard.nextInt();

        for (int i = 0; i < n; i++) {
            if (i == 10) {
                break;
            }
            keyboard.nextLine();
            System.out.printf("Hotel %d\n", i + 1);
            System.out.printf("Name : ");
            hotelNameArray[i] = keyboard.nextLine();
            System.out.printf("Owner's name : ");
            ownerNameArray[i] = keyboard.nextLine();
            System.out.printf("Location : ");
            locationArray[i] = keyboard.nextLine();
            System.out.printf("Tariff : ");
            tariffArray[i] = keyboard.nextDouble();
        }
    }

    public void searchHotel() {
        // Nhập tên Owner, in ra thông tin khách sạn của Owner này
        Scanner keyboard = new Scanner(System.in);
        System.out.printf("Owner's name : ");
        String ownerName = keyboard.nextLine();
        int i;
        for (i = 0; i < n; i++) {
            if (ownerName.equals(ownerNameArray[i])) {
                System.out.printf("Hotel name : %s\n", hotelNameArray[i]);
                System.out.printf("Owner's name : %s\n", ownerNameArray[i]);
                System.out.printf("Location : %s\n", locationArray[i]);
                System.out.printf("Tariff : %f\n", tariffArray[i]);
                //break;
            }
        }

        if (i >= n) {
            System.out.printf("Owner's name not found");
        }
    }
}